- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.2k
[Android][CoreCLR] Use runtimeconfig.bin for runtime configuration lookup in ApkBuilder #118674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: davidnguyen-tech <[email protected]>
…-specific runtimeconfig.json Co-authored-by: davidnguyen-tech <[email protected]>
…timeConfigProperties Co-authored-by: davidnguyen-tech <[email protected]>
…ection.Metadata Co-authored-by: davidnguyen-tech <[email protected]>
Co-authored-by: davidnguyen-tech <[email protected]>
| /azp run runtime-android,runtime-androidemulator | 
| Azure Pipelines successfully started running 2 pipeline(s). | 
| /azp run runtime-android,runtime-androidemulator | 
| Azure Pipelines successfully started running 2 pipeline(s). | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug in the AndroidAppBuilder where it was incorrectly looking for {ProjectName}.runtimeconfig.json instead of the actual generated file {AssemblyName}.runtimeconfig.json, causing test failures. The solution switches to using the standardized runtimeconfig.bin binary format for runtime configuration lookup.
Key Changes:
- Modified ParseRuntimeConfigPropertiesmethod to read fromruntimeconfig.bininstead of guessing JSON filenames
- Implemented binary format parsing using BlobReaderfromSystem.Reflection.Metadata
- Added unsafe code support to enable direct memory access for efficient binary reading
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description | 
|---|---|
| src/tasks/AndroidAppBuilder/ApkBuilder.cs | Replaced JSON-based runtime config parsing with binary format reading using BlobReader | 
| src/tasks/AndroidAppBuilder/AndroidAppBuilder.csproj | Added AllowUnsafeBlocks property to enable unsafe code for binary reading | 
| src/tasks/TestExclusionListTasks/TestExclusionListTasks.csproj | Added AllowUnsafeBlocks property (appears unrelated to main changes) | 
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| Tagging subscribers to this area: @hoyosjs | 
The AndroidAppBuilder was incorrectly looking for
{ProjectName}.runtimeconfig.jsonwhen the actual generated file is named{AssemblyName}.runtimeconfig.json, causing the CoreCLR Android test host to fail finding the runtime configuration file.Problem
When building Android apps and especially when running tests:
mainLibraryFileNameis set toAndroidTestRunner.dllAndroidTestRunner.runtimeconfig.jsonfor all tests is incorrect as each test project has its own configurationCould not find file 'HelloAndroid.runtimeconfig.json'Solution
Modified the
ParseRuntimeConfigPropertiesmethod to use the standardizedruntimeconfig.binfile instead of trying to guess the correct JSON filename. This binary file is created by MSBuild'sRuntimeConfigParserTaskand contains the same configuration properties in a binary format.The implementation uses the existing
BlobReaderfromSystem.Reflection.Metadatato read the binary format, which provides the necessaryReadCompressedInteger()andReadSerializedString()methods that mirror theBlobBuilderwrite operations.Before:
After:
The solution maintains the same functionality of extracting configProperties for the CoreCLR Android template while working reliably for both apps and test scenarios.
Fixes #118162.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.